package com.zzw.springboot.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 采购单实体类
 */
@TableName("t_purchase")
public class Purchase implements Serializable {
    // 采购单ID
    @TableId(value = "purchase_id", type = IdType.AUTO)
    private Integer purchaseId;

    // 采购单号
    @NotEmpty(message = "采购单号不能为空")
    private String purchaseNo;

    // 供应商ID
    @NotNull(message = "供应商ID不能为空")
    private Integer supplierId;

    // 采购总金额
    private BigDecimal totalAmount;

    // 状态：0-草稿，1-审核中，2-已审核，3-已入库，4-已完成，-1-已取消
    private Integer status;

    // 采购日期
    @NotNull(message = "采购日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date purchaseDate;

    // 预计到货日期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date expectedDate;

    // 审批人ID
    private Integer approvalUserId;

    // 审批时间
    private Date approvalTime;

    // 创建人ID
    private Integer creatorId;

    // 备注
    private String remark;

    // 创建时间
    private Date createTime;

    // 更新时间
    private Date updateTime;

    // 非数据库字段
    // 供应商名称
    @TableField(exist = false)
    private String supplierName;

    // 创建人姓名
    @TableField(exist = false)
    private String creatorName;

    // 审批人姓名
    @TableField(exist = false)
    private String approvalUserName;

    // 采购单明细列表
    @TableField(exist = false)
    private List<PurchaseItem> items;

    public Integer getPurchaseId() {
        return purchaseId;
    }

    public void setPurchaseId(Integer purchaseId) {
        this.purchaseId = purchaseId;
    }

    public String getPurchaseNo() {
        return purchaseNo;
    }

    public void setPurchaseNo(String purchaseNo) {
        this.purchaseNo = purchaseNo;
    }

    public Integer getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Integer supplierId) {
        this.supplierId = supplierId;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getPurchaseDate() {
        return purchaseDate;
    }

    public void setPurchaseDate(Date purchaseDate) {
        this.purchaseDate = purchaseDate;
    }

    public Date getExpectedDate() {
        return expectedDate;
    }

    public void setExpectedDate(Date expectedDate) {
        this.expectedDate = expectedDate;
    }

    public Integer getApprovalUserId() {
        return approvalUserId;
    }

    public void setApprovalUserId(Integer approvalUserId) {
        this.approvalUserId = approvalUserId;
    }

    public Date getApprovalTime() {
        return approvalTime;
    }

    public void setApprovalTime(Date approvalTime) {
        this.approvalTime = approvalTime;
    }

    public Integer getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(Integer creatorId) {
        this.creatorId = creatorId;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public String getApprovalUserName() {
        return approvalUserName;
    }

    public void setApprovalUserName(String approvalUserName) {
        this.approvalUserName = approvalUserName;
    }

    public List<PurchaseItem> getItems() {
        return items;
    }

    public void setItems(List<PurchaseItem> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        return "Purchase{" +
                "purchaseId=" + purchaseId +
                ", purchaseNo='" + purchaseNo + '\'' +
                ", supplierId=" + supplierId +
                ", totalAmount=" + totalAmount +
                ", status=" + status +
                ", purchaseDate=" + purchaseDate +
                ", expectedDate=" + expectedDate +
                ", approvalUserId=" + approvalUserId +
                ", approvalTime=" + approvalTime +
                ", creatorId=" + creatorId +
                ", remark='" + remark + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", supplierName='" + supplierName + '\'' +
                ", creatorName='" + creatorName + '\'' +
                ", approvalUserName='" + approvalUserName + '\'' +
                '}';
    }
}
